import router from '@/router'
import { useUserStore } from '@/stores'

const whiteList = ['/login']

router.beforeEach((to, from, next) => {
  document.title = to.meta.title || '后台管理系统'
  const userStore = useUserStore()
  if (!userStore.token && !whiteList.includes(to.path)) {
    console.log('没有token')
    return next('/login')
  }
  next()
})
